package xw.qxypt.modules.baseinfo.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import xw.qxypt.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import xw.qxypt.modules.baseinfo.entity.LhpDataVisibilityEntity;
import xw.qxypt.modules.baseinfo.entity.LhpDataVisibilityHistoryEntity;
import xw.qxypt.modules.baseinfo.service.LhpDataVisibilityService;
import xw.qxypt.common.utils.PageUtils;
import xw.qxypt.common.utils.R;



/**
 * 
 *
 * @author xw
 * @email 
 * @date 2019-11-28 16:38:08
 */
@RestController
@RequestMapping("baseinfo/lhpdatavisibility")
public class LhpDataVisibilityController {
    @Autowired
    private LhpDataVisibilityService lhpDataVisibilityService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = lhpDataVisibilityService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("baseinfo:lhpdatavisibility:info")
    public R info(@PathVariable("id") String id){
        LhpDataVisibilityEntity lhpDataVisibility = lhpDataVisibilityService.getById(id);

        return R.ok().put("lhpDataVisibility", lhpDataVisibility);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("baseinfo:lhpdatavisibility:save")
    public R save(@RequestBody LhpDataVisibilityEntity lhpDataVisibility){
        lhpDataVisibilityService.save(lhpDataVisibility);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("baseinfo:lhpdatavisibility:update")
    public R update(@RequestBody LhpDataVisibilityEntity lhpDataVisibility){
        ValidatorUtils.validateEntity(lhpDataVisibility);
        lhpDataVisibilityService.updateById(lhpDataVisibility);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("baseinfo:lhpdatavisibility:delete")
    public R delete(@RequestBody String[] ids){
        lhpDataVisibilityService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }
    /**
     * 首页能见度信息chart
     */
    @RequestMapping("/visibilityChart")
    public R roadChart() {
        Map map=lhpDataVisibilityService.visibilityChart();
        return R.ok().put("data",map);
    }
    /**
     * 首页能见度参数图层
     */
    @RequestMapping("/visibilityOverlay")
    public R visibilityOverlay() {
        List<LhpDataVisibilityEntity> list=lhpDataVisibilityService.visibilityOverlay();
        return R.ok().put("data",list);
    }
    /**
     * 信息
     */
    @RequestMapping("/getDataVisibilityByPointId/{pointId}")
    public R getDataVisibilityByPointId(@PathVariable("pointId") String pointId){
        LhpDataVisibilityEntity lhpDataVisibility = lhpDataVisibilityService.getDataVisibilityByPointId(pointId);

        return R.ok().put("lhpDataVisibility", lhpDataVisibility);
    }
    /**
     * 3小时数据用于构建图表
     */
    @RequestMapping("/visibilityDataChart/{pointId}")
    public List<LhpDataVisibilityEntity> visibilityDataChart(@PathVariable("pointId") String pointId){
        List<LhpDataVisibilityEntity> list = lhpDataVisibilityService.visibilityDataChart(pointId);
        return list;
    }

}
